package org.pvt.model.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import org.pvt.model.Model;
import org.pvt.model.Models;

/**
 * @author Pavel Talanov
 */
/*package*/ final class OpenHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "bill_splitter.db";
    private static final int DATABASE_VERSION = 1;

    public OpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        for (Model model : Models.All) {
            sqLiteDatabase.execSQL(model.getCreationSQL());
        }
        Log.i("DB", "Db created");
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        //do nothing
    }
}
